package gui;

import java.awt.Color;
import java.awt.Graphics;

import core.Main;

/**
 * A menu-object with a text that calls a sub-menu when triggered.
 * @author nick-luca.frank
 *
 */
public class MenuObj {
	private int index;
	private String text;
	private int triggeredMenu;
	private boolean triggered;
	/**
	 * Initializes the MenuObject.
	 * @param subMenu the submenu to add it to
	 * @param text the text
	 * @param triggeredMenu the sub-menu that it calls when activated
	 */
	public MenuObj(int index, String text, int triggeredMenu){
		this.index =index;
		this.text = text;
		this.triggeredMenu = triggeredMenu;
		this.triggered = false;
	}
	/**
	 * Sets the MenuObject as trigerred.
	 * @return the menu that is called
	 */
	public int trigger(){
		triggered = true;
		return triggeredMenu;
	}
	
	/**
	 * @return whether the MenuObject got trigerred
	 */
	public boolean gotTriggered(){
		if(triggered){
			triggered = false;
			return true;
		}else{
			return false;
		}
	}
	
	/**
	 * Draws the MenuObject's text.
	 * @param g the Graphics-handle to draw with
	 */
	public void render(Graphics g){
		g.setFont(GUI.font);
		g.setColor(Color.WHITE);
		g.drawString(text, Main.WIDTH - 250, GUI.font.getSize() + index * 64);
	}
}
